package test;

import org.bhf.facilities.Project;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;

public class ProjectFilter implements Filter
{
    public void init( FilterConfig filterConfig ) throws ServletException
    {
    }

    public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain ) throws IOException, ServletException
    {
       final Project p = Project.setProject( new Project( "foo.bar" ) );
        try
        {
            filterChain.doFilter( servletRequest, servletResponse );
        }
        finally
        {
            Project.setProject( p );
        }
    }

    public void destroy()
    {
    }
}
